package com.apes.scm.statement.customerConsignStatement.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.statement.customerConsignStatement.model.CustomerConsignStatementItem;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

public interface CustomerConsignStatementItemRepository extends CustomRepository<CustomerConsignStatementItem,String> {

    @Query(
            value = "select new map(s.id as id, s.priceUnit as priceUnit, s.pendingQty as pendingQty, s.amount as amount, s.statementQty as statementQty," +
                    "               p.id as productId , p.name as productName, u.id as uomId, u.name as uomName, t.id as taxId, t.name as taxName, f.id as inventoryConsignId)" +
                    "from CustomerConsignStatementItem s left join s.inventoryConsign f left join s.product p left join s.uom u left join s.tax t " +
                    "where s.customerConsignStatement.id = ?1"
    )
    List<Map<String,Object>> findAllByCustomerConsignStatementId(String statementId);
}
